#ifndef _TA_PROTOCOL__H
#define _TA_PROTOCOL__H
#include "stdint.h"

typedef struct
{
    uint8_t *bytes;
    uint16_t len;
} TA_BytesArray;

typedef struct
{
    uint8_t      Package_ID;         //包ID
    uint8_t      FrameType;          //帧长度   0x01：单帧  其他 多帧
	  uint8_t      Frame_sn;           //帧序号
    uint8_t      data_len;           //数据长度
    uint8_t      *data;              //数据
} TA_Protocol;
/*********************************
 * TA协议解析控制块
 * ******************************/
typedef struct
{
    uint8_t        parse_pointer;                                    //协议解析指针
    uint8_t        *data_buf;                                        //解析数据缓存
    uint8_t        Buf_Size;                                         //缓存区大小
    TA_Protocol    protocol;                                      //命令数据
    TA_BytesArray (*Parse)(TA_Protocol, uint8_t *connand_buf); //解析函数
} TA_Protocol_TCB;

void TA_Create(TA_Protocol_TCB *tcb, TA_BytesArray (*Parse)(TA_Protocol, uint8_t *), uint8_t *buf, uint8_t size); //创建TA 协议解析
TA_BytesArray TA_Decode_Array(TA_Protocol_TCB *tcb, uint8_t *data, uint8_t len);                                  //解码数据,逐条解码
uint8_t TA_Package(TA_Protocol protocol, uint8_t *bytes);
#endif

